﻿using Benlai.Model.Common;
using Benlai.Dac.Common;
using Benlai.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Benlai.Bll.Common
{
    public class NavigationManager
    {
        private static List<NavigationModel> navlist = new List<NavigationModel>();

        public NavigationManager()
        {
            if (navlist == null || navlist.Count <= 0)
                navlist = GetList();
        }

        public List<NavigationModel> GetList()
        {
            if (navlist != null && navlist.Count > 0)
                return navlist;

            NavigationDac dac = new NavigationDac();
            dac.SortPropertyName = "no";
            int recordCount = 0;
            navlist = dac.GetList(1, 2000, out recordCount);
            if (navlist == null)
                navlist = new List<NavigationModel>();
            return navlist;
        }

        public NavigationModel Get(string no)
        {
            NavigationDac dac = new NavigationDac();
            dac.SortPropertyName = "no";
            var list = dac.Get(no);
            if (list == null || list.Count <= 0)
                return null;
            return list[0];
        }

        public void Set(NavigationModel model)
        {
            NavigationDac dac = new NavigationDac();
            dac.Set(model);
        }
    }
}
